package com.dingwen.treasure.business.component.task;

import com.dingwen.treasure.base.enums.TaskGenerateType;
import com.dingwen.treasure.business.model.dto.TaskGenerateDto;
import com.dingwen.treasure.business.model.entity.TaskGenerate;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;

/**
 * 　MonthTaskGenerate： 按照自然月生成任务
 * 　@author dingwen
 * 　@date 2022/8/4
 */
@Component
@Slf4j
public class MonthTaskGenerate extends AbstractTaskGenerate {

    /**
     * 初始化
     */
    @PostConstruct
    public void init() {
        this.generateType = TaskGenerateType.MONTH;
    }

    /**
     * 生成
     *
     * @param taskGenerateDTO 任务生成dto
     * @return {@link Optional}<{@link List}<{@link TaskGenerate}>>
     */
    @Override
    protected Optional<List<TaskGenerate>> generate(TaskGenerateDto taskGenerateDTO) {
        log.info("按照自然月生成任务");
        return Optional.ofNullable(Arrays.asList(TaskGenerate.builder().build()));
    }
}
